The file system of many computer operating systems, such as the UNIX operating system, uses a disk buffer cache to improve the performance of hard disk access functions. The disk buffer cache scheme allows faster access of hard disk data by caching or storing some of the disk data in RAM (random access memory). In this manner, data access time is decreased whenever a piece of needed data can be acquired by accessing RAM instead of the hard disk. However, the use of the buffer cache makes the file system prone to data inconsistency in the event of abnormal system shutdowns.
A modification made to data in a file system typically occurs as a sequence of changes to individual blocks on the disk. Such a modification is generally termed a transaction, which may be defined as an operation that takes the file system from one consistent state to another consistent state. Therefore, the sequence of changes in a transaction may be vital in maintaining the atomicity of the transaction, so that the individual changes within the transaction are seemingly indivisible and instantaneous.
In the cache buffer scheme, disk data that were modified are written to disk only when they are forced out of the cache on a least recently used basis or another similar method. Therefore, the sequence of changes to the disk is usually, and almost always, different than the sequence in which the data were modified. For example, if the transaction has 3 steps, change in step 3 that is dependent on step 2 could be written to disk while the change in step 2 remains in the cache. In the event of an abnormal system shutdown, the change to disk data in step 2 would be lost, yet the change in step 3 would be saved. This causes the disk to be left in an inconsistent state.
One solution to this problem is to periodically write all of the modified data contained in the cache buffers to disk. However, this solution only mitigates the amount of damage, but does not eliminate the problem. Additionally, users of the system may encounter momentary loss of response from the system during the write operations. The UNIX operating system attempts to resolve the problem by using this periodic-write scheme.
Another solution is to restore the sequence of modifications of blocks by operating the cache as a "write through" cache and strictly maintaining the order of the block modifications. Although ensuring the integrity of the disk, this solution has adverse impact on performance because it removes all the advantages of using a cache to delay disk writes. Therefore, this method is used only to protect the most sensitive data.
Therefore, it is desirable to protect the integrity of the file system and yet not substantially hinder the benefits of the buffer cache. The present invention provides a logging apparatus and method for disk file systems.